<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原型链继承</title>
    <script type="text/javascript">
        //父类
        function Super(){
            this.sa = 'sa';
        }
        Super.prototype.superMethod = function(){
            console.log('我是父类的方法');
        }

        function Children(){
            this.ca ='children';
        }
        //将子类的原型对象指定为父类的实例对象，类似于隐藏语句 this.prototype = {}
        Children.prototype = new Super(); //这个语句需要在添加其他原型对象属性之前写，不然之前添加的原型对象属性都还在之前的空的Object对象上，后面使用就找不到了
        Children.prototype.constructor = Children;
        Children.prototype.childrenMethod = function(){
            console.log('我是子类的方法');
        }

        var children = new Children();
        children.superMethod()//子类调用到父类的方法
        console.log(children);
        console.log(Children.prototype);
        children.childrenMethod();
        console.log(Children.prototype.constructor);
    </script>
</head>
<body>
    
</body>
</html>